#include <unistd.h>
#include <mutex>
#include "sys.h"
#include "MainPage.h"

using namespace std;

static void mainPageExitCallback(void);

static mutex uiMutex;
static MainPage *mainPage;

int main(void)
{
    sys_init();
    lv_init(); // lvgl gui初始化
    lv_port_disp_init();
    lv_port_indev_init();
    lv_port_fs_init();

    mainPage = new MainPage(mainPageExitCallback, uiMutex);

    while (1)
    {
        uiMutex.lock();
        uint32_t ms = lv_task_handler();
        uiMutex.unlock();

        usleep(ms * 1000);
    }
}

/**
 *@brief picture退出回调函数
 */
static void mainPageExitCallback(void)
{
    delete mainPage;

    exit(0);
}
